<?php

function FilmStrip($images, $index, $width, $height, $logo) {  //$index is integer pointer to first image for strip
    $space = 3;
    $my_img = imagecreatetruecolor($width, $height);
    $hole = imagecreatetruecolor(8, 12);
    $background = imagecolorallocate($my_img, 0x1e, 0x1e, 0x1e);
    $holecolour = imagecolorallocate($hole, 0xc7, 0xc7, 0xc7);
    $shadowcolour = imagecolorallocate($my_img, 0x00, 0x00, 0x00);
    $textcolour = imagecolorallocate($my_img, 0xff, 0xff, 0xff);
    imagefill($hole, 0, 0, $holecolour);
    imagefill($my_img, 0, 0, $background);
    imagesetthickness($my_img, 24);
    $dst_x = 0;
    $top_y = 9;
    $bot_y = imagesy($my_img) - imagesy($hole) - 9;
    while ($dst_x < imagesx($my_img)) {
        imagecopy($my_img, $hole, $dst_x, $top_y, 0, 0, imagesx($hole), imagesy($hole));
        imagecopy($my_img, $hole, $dst_x, $bot_y, 0, 0, imagesx($hole), imagesy($hole));
        $dst_x += 20;
    }
    $dst_x = $space;
    $top_y = 12 + 9 + $space;
    $imagesize = $height - ($top_y * 2);
    $count = count($images);
    

    //prefix logo...
        $src_image = imagecreatefromjpeg($logo);
        $width = imagesx($src_image);
        $height = imagesy($src_image);
        $downwidth = ($width / 1000);
        $downheight = ($height / $imagesize);
        if ($downheight >= $downwidth) {
            $down = $downheight;
        } else {
            $down = $downwidth;
        }
//        $newwidth = intval($width / $down);
//        $newheight = intval($height / $down);
//        imagecopyresized($my_img, $src_image, $dst_x, $top_y, 0, 0, $newwidth, $newheight, $width, $height);
        imagecopy($my_img, $src_image, 0, 0, 0, 0, $width, $height);
        $dst_x = $dst_x + /*$new*/$width + $space;
    
    while ($dst_x < imagesx($my_img)) {
        $src_image = imagecreatefromjpeg($images[$index]);
        $width = imagesx($src_image);
        $height = imagesy($src_image);
        $downwidth = ($width / 1000);
        $downheight = ($height / $imagesize);
        if ($downheight >= $downwidth) {
            $down = $downheight;
        } else {
            $down = $downwidth;
        }
        $newwidth = intval($width / $down);
        $newheight = intval($height / $down);
        imagecopyresized($my_img, $src_image, $dst_x, $top_y, 0, 0, $newwidth, $newheight, $width, $height);
        $dst_x = $dst_x + $newwidth + $space;
        $next = $index + 1;
        $index = $next % $count;
    }
    $textspacing = 300;
    $textstartx = 200;
    imagestring($my_img, 1, $textstartx, 0, 'SOUTH KILDARE PHOTOGRAPHY CLUB', $textcolour);
    $textstartx = $textstartx + $textspacing;
    imagestring($my_img, 1, $textstartx, 172, 'SOUTH KILDARE PHOTOGRAPHY CLUB', $textcolour);
    $textstartx = $textstartx + $textspacing;
    imagestring($my_img, 1, $textstartx, 0, 'SOUTH KILDARE PHOTOGRAPHY CLUB', $textcolour);
    $textstartx = $textstartx + $textspacing;
    imagestring($my_img, 1, $textstartx, 172, 'SOUTH KILDARE PHOTOGRAPHY CLUB', $textcolour);
    $textstartx = $textstartx + $textspacing;
    imagestring($my_img, 1, $textstartx, 0, 'SOUTH KILDARE PHOTOGRAPHY CLUB', $textcolour);
    $textstartx = $textstartx + $textspacing;
    imagestring($my_img, 1, $textstartx, 172, 'SOUTH KILDARE PHOTOGRAPHY CLUB', $textcolour);
    $textstartx = $textstartx + $textspacing;
    imagestring($my_img, 1, $textstartx, 0, 'SOUTH KILDARE PHOTOGRAPHY CLUB', $textcolour);
    $textstartx = $textstartx + $textspacing;
    imagestring($my_img, 1, $textstartx, 172, 'SOUTH KILDARE PHOTOGRAPHY CLUB', $textcolour);
    $textstartx = $textstartx + $textspacing;
    imagedestroy($hole);
    return $my_img;
}

?>
